package com.yiwei.ydd.fragment;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yiwei.ydd.R;
import com.yiwei.ydd.activity.WebViewActivity;
import com.yiwei.ydd.constant.UserInfoGlobal;
import com.yiwei.ydd.util.Util;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

import static com.yiwei.ydd.util.Util.getStatusBarHeight;

/**
 * Created by xsooy-pc on 17-12-4.
 */

public class MainDiscoverFragment extends BaseFragment {
    @BindView(R.id.view_top)
    View viewTop;
    Unbinder unbinder;
    @BindView(R.id.view_red)
    View viewRed;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_main_discover;
    }

    @Override
    protected void initView() {
        viewTop.post(new Runnable() {
            @Override
            public void run() {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    int height = getStatusBarHeight(getContext());
                    if (height == 0) {
                        return;
                    }
                    ViewGroup.LayoutParams lp = viewTop.getLayoutParams();
                    lp.height = height;
                    viewTop.setLayoutParams(lp);
                }
            }
        });
    }

    public void setViewRedVisible(int redVisible) {
        viewRed.setVisibility(redVisible);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick(R.id.img_msg_tips)
    public void onViewClicked() {

    }

    @OnClick({R.id.btn_jd, R.id.btn_tb, R.id.btn_yms, R.id.btn_dd})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_jd:
                Intent intent1=new Intent(getActivity(), WebViewActivity.class);
                intent1.putExtra("url","https://www.jd.com/");
                startActivity(intent1);
                break;
            case R.id.btn_tb:
                Intent intent2=new Intent(getActivity(), WebViewActivity.class);
                intent2.putExtra("url","https://www.suning.com");
                startActivity(intent2);
                break;
            case R.id.btn_yms:
                Intent intent3=new Intent(getActivity(), WebViewActivity.class);
                intent3.putExtra("url","https://www.amazon.cn/");
                startActivity(intent3);
                break;
            case R.id.btn_dd:
                Intent intent4=new Intent(getActivity(), WebViewActivity.class);
                intent4.putExtra("url","http://www.yhd.com");
                startActivity(intent4);
                break;
        }
    }
}
